package menuedit;

import guis.FunctionalControls;

import java.util.Date;
import java.util.List;

import org.eclipse.swt.widgets.Composite;

import dao.DataLoader;
import datacontainers.Category;
import datacontainers.Dish;

public class MenuEditControls implements FunctionalControls, MenuEditInterface {

	MenuEditGUI gui;
	DataLoader dao;
	MenuEditor menu;

	public MenuEditControls(Composite tshell, DataLoader dao) {
		gui = new MenuEditGUI(this, tshell);
		menu = new MenuEditor();
		this.dao = dao;
		menu.setMenu(dao.getMenu());

		gui.showMenu(menu.getMenu());

	}

	public void saveMenu() {
		dao.saveMenu(menu.getMenu());
	}

	public List<Dish> getDishVariants(Category cat, String mask) {
		return dao.getAllDishes().findByNameCategory(cat, mask);
	}

	@Override
	public void close() {
		gui.close();
	}

	@Override
	public void addDish(Dish dish) {
		menu.addDish(dish);
		// gui.showMenu(menu.getMenu());
	}

	@Override
	public void updateDish(Dish dish) {
		menu.updateDish(dish);
		gui.showMenu(menu.getMenu());
	}

	@Override
	public void deleteDish(Dish dish) {
		menu.deleteDish(dish);
		gui.showMenu(menu.getMenu());
	}

	@Override
	public void setActualDate(Date date) {
		// TODO Auto-generated method stub

	}

}
